import shutil
import os
import random


def find_file(path, type):
    path_list = []
    for root, dirs, files in os.walk(path):
        for name in files:
            if name.endswith(type):
                path_list.append(os.path.join(root, name))
    
    return path_list


if __name__ == "__main__":
    path = r"data/ori_data/4.19_crop"
    dst_path = r"data/shushu/train/No2"

    img_list = find_file(path, "jpg")

    # random.shuffle(img_list)

    selected_img = img_list#[:18]

    for img_p in selected_img:
        json_p = img_p.replace('.jpg', '.json')

        img_p_dst = os.path.join(dst_path, os.path.basename(img_p))
        json_p_dst = os.path.join(dst_path, os.path.basename(json_p))

        shutil.move(img_p, img_p_dst)
        shutil.move(json_p, json_p_dst)

    print('ok')